﻿Namespace Common
    Public Class NotifyBase
        Implements INotifyPropertyChanged

        Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged

        Protected Function SetProperty(Of T)(ByRef field As T, value As T,
                    <CallerMemberName> Optional callerMemberName As String = Nothing) As Boolean
            If Object.Equals(field, value) Then Return False

            OnPropertyChanged(callerMemberName)
            field = value
            Return True
        End Function

        Protected Sub OnPropertyChanged(
                <CallerMemberName> Optional callerMemberName As String = Nothing)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(callerMemberName))
        End Sub
    End Class
End Namespace